package com.wfc.servlet.user;


import com.wfc.entity.User;
import com.wfc.service.UserService;
import com.wfc.service.serviceImpl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/username")
public class isUser extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String username = req.getParameter("username1");
        UserService userService = new UserServiceImpl();
        User news_user1 =null;
        news_user1 = userService.ServiceByUsername(username);
        resp.setCharacterEncoding("utf-8");
        PrintWriter writer = resp.getWriter();

            if(username.equals(news_user1.getUsername())){
                writer.println("昵称存在");
            }else {
                writer.println("昵称不存在");
            }

        writer.flush();
        writer.close();
    }
}
